package model;

/**
 *
 * @author Dustin
 */
public abstract class Player {

    /*
     * The size of a hand of cards
     */
    public final static int HAND_SIZE = 3;
    private int points;
    private boolean lastTurn;
    private String name;
    private Card[] hand = new Card[HAND_SIZE];

    public Player(String aName) {
        name = aName;
    }

    public int getPoints() {
        return points;
    }

    public boolean isLastTurn() {
        return lastTurn;
    }

    public String getName() {
        return name;
    }

    public Card getCard(int index) {
        return hand[index];
    }

    public Card[] getHand() {
        return hand;
    }

    public void setPoints(int somePoints) {
        points = somePoints;
    }

    public void setLastTurn(boolean aValue) {
        lastTurn = aValue;
    }

    public void setName(String aName) {
        name = aName;
    }

    public void setCard(int index, Card c) {
        hand[index] = c;
    }

    public void resetHand() {
        for(int i = 0; i < HAND_SIZE; i++) {
            hand[i] = null;
        }
    }

    public void swapCard(Table t, int ownIndex, int tableIndex) {
        Card temp = t.getCard(tableIndex);
        t.setCard(tableIndex, hand[ownIndex]);
        setCard(ownIndex, temp);
    }

    public void swapCards(Game g) {
        for(int i = 0; i < getHand().length; i++) {
            swapCard(g.getTable(), i, i);
        }
        pass(g);
    }

    public void pass(Game g) {
        setLastTurn(true);
    }
}
